package com.mall.shopping.dto;

import com.mall.commons.result.AbstractRequest;
import com.mall.commons.tool.exception.ValidateException;
import com.mall.shopping.constants.ShoppingRetCode;
import lombok.Data;

/**
 * Created on 2019/7/23.
 */
@Data
public class AddCartRequest extends AbstractRequest {

    private Long userId;
    private Long itemId;
    private Integer num;

    @Override
    public void requestCheck() {

        if (userId == null || userId <= 0 || itemId == null || itemId <= 0 || num == null || num <= 0) {
            //参数校验失败
            throw new ValidateException(ShoppingRetCode.PARAMETER_VALIDATION_FAILED.getMessage(),
                    ShoppingRetCode.REQUEST_CHECK_FAILURE.getCode());
        }
    }
}
